package com.example.sportzbreak;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.format.Time;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends Activity {

	private TextView textView1;
	private TextView textViewDate;
	private ImageButton btnPlay;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		// Referencias widgets
		textViewDate = (TextView) findViewById(R.id.textViewDate);
		textView1 = (TextView) findViewById(R.id.textView1);
		btnPlay = (ImageButton) findViewById(R.id.PlayBtn1);
		
		// btnPlay listener
		btnPlay.setOnClickListener(new OnClickListener()
		{
			public void onClick(View view){
				LaunchEventActivity();
			}
		});	
		
		textView1.setTypeface(null, Typeface.BOLD);
		
		// Toma fecha actual
		Time today = new Time(Time.getCurrentTimezone());
		today.setToNow();
		
		Calendar calendar = Calendar.getInstance();
		int day = calendar.get(Calendar.DAY_OF_WEEK);
		String daysOfWeek[] = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
		String months[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};		
		
		String currentDate = daysOfWeek[day-2]+" "+today.monthDay+" "+months[today.month-1]+" "+today.year;
		
		// Coloca fecha con formato deseado en textView
		textViewDate.setText(currentDate);         
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void LaunchEventActivity() {
	    Intent i = new Intent(this, EventActivity.class);
	    startActivity(i);
	}
	
}